﻿@namespace AntSK.Pages.FunPage
@using AntSK.Domain.Repositories
@using AntSK.Domain.Domain.Model.Enum
@using AntSK.Domain.Domain.Model.Fun
@page "/plugins/funlist"
@inject NavigationManager NavigationManager
@using AntSK.Services.Auth
@inherits AuthComponentBase

<PageContainer Title="函数列表">
    <Content>
        <div style="text-align: center;">
            <Search Placeholder="输入回车"
                    EnterButton="@("搜索")"
                    Size="large"
                    Style="max-width: 522px; width: 100%;"
                    OnSearch="Search" />
        </div>
    </Content>
    <ChildContent>
        <div class="cardList">
            <AntList TItem="FunDto"
                     DataSource="_data"
                     ItemLayout="ListItemLayout.Horizontal"
                     Grid="LayoutModel._listGridType">
                <ListItem NoFlex>
                    @if (string.IsNullOrEmpty(context.Name))
                    {
                        <Button Type="dashed" class="newButton" @onclick="AddFun">
                            <Icon Type="plus" Theme="outline" /> 创建函数
                        </Button>
                        <Button Type="dashed" class="newButton" @onclick="ClearFun">
                            <Icon Type="clear" Theme="outline" /> 清空导入函数
                        </Button>
                    }
                    else
                    {
                        <Card Hoverable Bordered Class="card"  Style="max-height:247px;">
                             <CardMeta>
                                 <AvatarTemplate>

                                 </AvatarTemplate>
                                 <TitleTemplate>
                                     <a>@context.Name</a>
                                </TitleTemplate>
                                <DescriptionTemplate>
                                    <Paragraph class="item" Ellipsis>
                                     <!--todo: Ellipsis not working-->
                                     @context.Description
                                    </Paragraph>
                                </DescriptionTemplate>
                            </CardMeta>
                        </Card>
                    }
                </ListItem>
            </AntList>
        </div>
    </ChildContent>
</PageContainer>


<Modal Title="插件导入"
       Visible="@_fileVisible"
       OnOk="@FileHandleOk"
       OnCancel="@FileHandleCancel"
       ConfirmLoading="@_fileConfirmLoading">
    <Upload Action="@("api/File/UploadFile")"
            Name="file"
            Drag
            Multiple
             Accept="*/*"
             BeforeUpload="BeforeUpload"
             OnSingleCompleted="OnSingleCompleted">
         <p class="ant-upload-drag-icon">
             <Icon Type="inbox" />
         </p>
         <p class="ant-upload-text">单击或拖动文件到此区域进行上传</p>
         <p class="ant-upload-hint">
             请上传dll文件
         </p>
     </Upload>
 </Modal>
@code
{
 
}
